import { getSpecialsPage } from '../../../../api/goods.js';
Component({
  /**
   * 组件的属性列表
   */
  properties: {},

  /**
   * 组件的初始数据
   */
  data: {
    shopList: [],
  },
  lifetimes: {
    ready() {
      this.init();
    },
  },
  /**
   * 组件的方法列表
   */
  methods: {
    async init() {
      const data = await getSpecialsPage();
      data.activities.list && data.activities.list.map(t => {
        t.seckillPrice = t.seckillPrice && (t.seckillPrice / 100).toFixed(2)
        t.marketPrice = t.marketPrice && (t.marketPrice / 100).toFixed(2)
        return t
      })
      this.setData({
        shopList: data.activities.list,
      });
    },
    runBuy() {
      wx.navigateTo({
        url: '/pages/goods/specials/index',
      });
    },
    runGoodsDetail(e) {
      const {item} = e.currentTarget.dataset
      wx.navigateTo({
        url: `/pages/goods/details/index?goodsId=${item.spuId}`,
      });
    }
  },
});
